class Solution1 {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
         int sum = 0 ; 
         int ret = timeSeries[0] + duration -1 ;
         for(int i = 1 ; i < timeSeries.length ; i++){
               if(timeSeries[i] <= ret){
                sum +=  timeSeries[i] - timeSeries[i-1] ;
                ret = timeSeries[i] + duration - 1 ;                           
               }else{
                  sum += duration ; 
                  ret = timeSeries[i] + duration-1 ;
               }
         }
         return sum + duration;

    }
}